package io.renren.modules.wx.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.wx.entity.QuestionBankEntity;
import io.renren.modules.wx.service.QuestionBankService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author linmingze
 * @email ${email}
 * @date 2022-10-19 10:08:18
 */
@RestController
@RequestMapping("wx/questionbank")
public class QuestionBankController {
    @Autowired
    private QuestionBankService questionBankService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wx:questionbank:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = questionBankService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bankId}")
    @RequiresPermissions("wx:questionbank:info")
    public R info(@PathVariable("bankId") Integer bankId){
		QuestionBankEntity questionBank = questionBankService.getById(bankId);

        return R.ok().put("questionBank", questionBank);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wx:questionbank:save")
    public R save(@RequestBody QuestionBankEntity questionBank){
		questionBankService.save(questionBank);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wx:questionbank:update")
    public R update(@RequestBody QuestionBankEntity questionBank){
		questionBankService.updateById(questionBank);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wx:questionbank:delete")
    public R delete(@RequestBody Integer[] bankIds){
		questionBankService.removeByIds(Arrays.asList(bankIds));

        return R.ok();
    }

}
